package com.arelikebrothers.demo.concurrent.begin;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lennon on 01/05/2017.
 */
public class ErrorArrayList {
    static List<Integer> list = new ArrayList<>();

    public static class AddThread implements Runnable {

        @Override
        public void run() {
            for (int i = 0; i < 1000; i++) {
                list.add(i);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new AddThread());
        Thread t2 = new Thread(new AddThread());

        t1.start();
        t2.start();

        t1.join();
        t2.join();
        System.out.println(list.size());
    }
}
